package com.xinzhidi.web.balancedview.controller;


import com.xinzhidi.common.core.controller.BaseController;
import com.xinzhidi.common.core.domain.AjaxResult;
import com.xinzhidi.common.core.domain.R;
import com.xinzhidi.web.balancedview.domain.po.BalanceLineChartPo;
import com.xinzhidi.web.balancedview.domain.po.BalancedViewPo;
import com.xinzhidi.web.balancedview.service.BalancedViewService;
import com.xinzhidi.web.house.domain.vo.HouseholdInfoVo;
import com.xinzhidi.web.netty.service.AgreementHouseholdValveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 平衡视图
 *
 * @author cx
 * @date 2023-06-25
 */
@RestController
@Api(tags = "平衡视图")
@RequestMapping("/balancedView")
@RequiredArgsConstructor
public class BalancedViewController extends BaseController {

    private final BalancedViewService balancedViewService;

    private final AgreementHouseholdValveService agreementHouseholdValveService;


    @ApiOperation("楼栋列表")
    @PostMapping("/getBuildList")
    public AjaxResult getBuildList(@Validated @RequestBody BalancedViewPo viewPo) {
        return AjaxResult.success(balancedViewService.getBuildList(viewPo));
    }

    @ApiOperation("单元住户列表")
    @PostMapping("/getUnitHousehold")
    public AjaxResult getUnitHousehold(@Validated @RequestBody BalancedViewPo viewPo) {
        return AjaxResult.success(balancedViewService.getUnitHousehold(viewPo));
    }

    @ApiOperation("住户基本数据-热量表数据")
    @PostMapping("/getHouseholdHeatData")
    public AjaxResult getHouseholdHeatData(@Validated @RequestBody BalancedViewPo viewPo) {
        return AjaxResult.success(balancedViewService.getHouseholdHeatData(viewPo));
    }

    @ApiOperation("住户基本数据-阀门开度")
    @GetMapping("/getHouseholdValveOpen")
    public AjaxResult getHouseholdValveOpen(Long householdId) {
        return AjaxResult.success(balancedViewService.getHouseholdValveOpen(householdId));
    }


    @ApiOperation("住户基本数据")
    @GetMapping("/getHouseholdInf")
    public R<HouseholdInfoVo> getHouseholdInf(@RequestParam("householdId") Long householdId) {
        return R.ok(balancedViewService.getHouseholdInf(householdId));
    }

    @ApiOperation("住户设备信息")
    @PostMapping("/getHouseholdEquipment")
    public AjaxResult getHouseholdEquipment(@Validated @RequestBody BalancedViewPo viewPo) {
        return AjaxResult.success(balancedViewService.getHouseholdEquipment(viewPo));
    }

    @ApiOperation("更新室温")
    @GetMapping("/updateTemperature")
    public AjaxResult updateTemperature(Long householdId) {
        return AjaxResult.success(balancedViewService.updateTemperature(householdId));
    }

    @ApiOperation("平衡视图-住户折线图")
    @PostMapping("/LineChart")
    public AjaxResult LineChart(@Validated @RequestBody BalanceLineChartPo chartPo) {
        return AjaxResult.success(balancedViewService.LineChart(chartPo));
    }




}
